<?php
	session_start();
	ob_start(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
include("connection/connection.php");

$username = $_POST['username'];
$password = md5($_POST['password']);

$query = "SELECT * FROM admin WHERE username ='$username' AND password = '$password'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
echo "Đăng nhập thành công.<br>";
header("Location:index.php");	
$_SESSION['username'] = $username;// Luu Session
if($_POST['remember'] == 'on')
{
setcookie("username",$username,time()+100); // Luu Cookie
}
echo "<a href='dangnhapForm.php'>Back</a>";
}
else
{
echo "Đăng nhập thất bại.<br>";
header("Location:index.php");
}
?>
</body>
</html>
